import { threeViewStore } from "../../store/models/data";
import pinia from '../../store/index';
const store = threeViewStore(pinia);
export default function clearOperate() {

    console.log(window.threeScene.children, 'window.threeScene');
    let index = 0;
    let len =4;
    while (window.threeScene.children.length > len) {
        if(window.threeScene.children[index].type ==='Mesh'){
            len+=1;
        }
        if (window.threeScene.children[index].type === "Points" || window.threeScene.children[index].type === "Line") {
            window.threeScene.remove(window.threeScene.children[index]);
            console.log(window.threeScene.children, index, 'window.threeScene.children');
        }
        else {
            index++;
            continue;
        }

    }
    store.objArr = [];//存放绘制的模型的数组--测高度
    store.lineObjArr = [];//存放线的模型数组--测高度
    store.labelTextArr = [];//存放标签模型的数组--测高度
    store.pointArrObj=  [];//存放绘制的点模型的数组---测角度
    store.lineArrObj= [];//存放绘制的线模型的数组---测角度
    store.pointArrVector3= [];//存放vector3格式点坐标的数组---测角度
    // 之后还要清空所有label
    //  let domArr = document.querySelectorAll('span');
    //  domArr.removeChild
    //  console.log(domArr,'domArr');
    //  for(let i=0;i<domArr.length;i++){
    //     domArr[i].innerHTML = '';
    //  }
    //  卸载span---把span建在body下的情况
    document.querySelectorAll("span").forEach(e => e.remove());
    // 把span建在某一标签下的情况
    // let e = document.getElementById('spanList');
    // var child = e.lastElementChild;  
    // while (child) { 
    //     e.removeChild(child); 
    //     child = e.lastElementChild; 
    // } 
}